<template>
  <div>
    <h1>Race List</h1>

    <div v-for="e in raceList">
      <a :href="'/Race?id=' + e.id">{{ e.id }}. {{ e.name }}</a>
    </div>

    <span>起名字</span>
    <input v-model="raceName"/>
    <input v-model="raceRound"/>
    <button @click="runRace">Run Race</button>
  </div>
</template>


<script>
export default {
  data() {
    return {
      raceName: '',
      raceRound: 100,
      raceList: []
    }
  },

  methods: {
    runRace() {
      if(!confirm("开始?")) {
        return
      }

      $post_form("/quant/race-run", {
        raceName: this.raceName,
        raceRound: this.raceRound
      }).then(res => {
        console.log("#25 race-run", res)
      })
    },

    loadData() {
      $post_json("/quant/race-list").then(res => {
        this.raceList = res.data
      })
    }
  },

  mounted() {
    this.loadData()
  }
}
</script>